home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / miscutl1.arc / COMSPEC.AQM / COMSPEC.ASM
Encoding:
Assembly Source File  |  1984-08-05  |  5.5 KB  |  144 lines

  1. title COMSPEC - Patch comspec parameter for hard/electronic disk.
  2. page 64,132
  3. comment |
  4.     /////////////////////////////////////////////////////////////////////
  5.     /  A Patch to DOS 2.0 to allow resetting of the COMSPEC parameter.  /
  6.     /                                    /
  7.     /  Page 10-23 of the DOS 2.0 manual clearly states the the COMSPEC  /
  8.     /  parameter is used to locate the command processor (COMMAND.COM)  /
  9.     /  when it needs to be reloaded.  Although the SET command may be   /
  10.     /  used to respecify the path, DOS does not seem to recognize it.   /
  11.     /                                    /
  12.     /  This program if included in the AUTOEXEC.BAT file at boot time   /
  13.     /  along with a SET command will cause DOS to reload COMMAND.COM    /
  14.     /  from wherever you wish.  My AUTOEXEC.BAT file looks like this:   /
  15.     /                                    /
  16.     /        ECHO ** AUTOEXEC.BAT **                    /
  17.     /        COMSPEC C:\DOS20\COMMAND.COM            DMO /
  18.     /        IF ERRORLEVEL 1 GOTO CSBAD                DMO /
  19.     /        SET COMSPEC=C:\DOS20\COMMAND.COM                /
  20.     /        GOTO CSCONT                     DMO /
  21.     /     :CSBAD                             /
  22.     /        ECHO COMSPEC ERROR                        /
  23.     /     :CSCONT                        DMO /
  24.     /                                    /
  25.     /  I have a TallGrass hard disk which is configured as drives C-F.  /
  26.     /  There is a sub-directory called \DOS20 with most of the DOS 2.0  /
  27.     /  commands and most importantly a copy of COMMAND.COM.  This idea  /
  28.     /  will also work from an electronic disk.  Just remember to copy   /
  29.     /  COMMAND.COM to the electronic disk in your AUTOEXEC.BAT file.    /
  30.     /                                    /
  31.     /           Ted Reuss    Houston, Tx    August 1983            /
  32.     /////////////////////////////////////////////////////////////////////
  33.  
  34.     / Fixed by Daniel M. O'Brien (21 August 1983). Problem was this
  35.     / program only searched the first 64k segment to find the COMSPEC
  36.     / string. With systems running DOS 2.0 VDISK (ramdisk) the COMSPEC
  37.     / string is located higher in memory. Fix was to loop thru all segments
  38.     / from 0 up to the segment containing this program.
  39.     / In addition, the new COMSPEC string was changed to reflect the
  40.     / use of VDISK as disk C:
  41.     / Finally, I want to thank Ted Reuss who developed the concepts
  42.     / and the original program as I have been battling this problem for
  43.     / about two months and it is now solved.
  44.     /
  45.     / Daniel M. O'Brien (29 August 1983). Specify where COMMAND.COM
  46.     / is to come from via command line parameter. Avoids having to
  47.     / patch or assemble correct values into place.
  48.     |
  49. cseg    segment public 'code'
  50.     assume    cs:cseg,ds:cseg
  51.     org    100h            ;use EXE2BIN to make .com
  52. start    proc    far
  53.     jmp    initial
  54.  
  55. oprm    db    'a:\COMMAND.COM',0      ;original comspec parameter
  56. ;note that the lower case 'a' is required so we don't match this
  57. ; string since it will be in a low memory disk buffer.
  58. oprm_l    equ    $-offset oprm
  59.  
  60. nprm    db    'C:\COMMAND.COM',0 ;user supplied parameter                  DMO
  61. nprm_l    equ    $-offset nprm
  62.     db    14 dup(0)    ;reserve space for patches
  63. nprm_len    dw    0    ;length of user suppled parameter         DMO
  64.  
  65. initial:
  66.     mov    ax,nprm_l    ;get default length                 DMO
  67.     mov    nprm_len,ax    ;initialize default length field         DMO
  68.  
  69.     cld            ;clear direction flag                 DMO
  70.     xor    ax,ax        ;clear ah,al                     DMO
  71.     mov    si,80h        ;point to input parm area             DMO
  72.     lods    byte [si]    ;get byte count                  DMO
  73.     or    al,al        ;any input?                     DMO
  74.     jz    no$input    ;no-use default                  DMO
  75.  
  76.     mov    cx,ax        ;get user input length                 DMO
  77. trim_blank:            ;                         DMO
  78.     mov    al,[si]     ;get next byte                     DMO
  79.     cmp    al,' '          ;leading blank?                              DMO
  80.     jne    blank_done    ;no-then done                     DMO
  81.     inc    si        ;skip leading blank                 DMO
  82.     loop    trim_blank    ;loop                         DMO
  83.  
  84. blank_done:            ;                         DMO
  85.  
  86.     mov    ax,cx        ;save length for update              DMO
  87.     mov    di,offset nprm    ;point to path variable              DMO
  88.     rep    movs [di],[si]    ;fill in our copy of value             DMO
  89.     mov    byte ptr [di],0 ;don't forget to include trailing zero       DMO
  90.     inc    ax        ;bump length by one for trailing zero         DMO
  91.     mov    nprm_len,ax    ;fill in length of user supplied path         DMO
  92.  
  93. no$input:            ;                         DMO
  94.  
  95.     xor    ax,ax
  96.     mov    es,ax        ;Scan for original comspec string
  97.     mov    di,ax        ; begins at 0000:0000.
  98. bigloop:            ;                         DMO
  99.     mov    cx,0ffffh    ;search entire segment                 DMO
  100.     cld            ;set auto-increment
  101. again:    mov    si,offset oprm+1  ;point to target string
  102.     mov    al,byte ptr[si-1] ;and fetch first character.
  103.     and    al,11011111B    ;force to upper case
  104.     repnz    scasb        ;loop while not equal
  105.     jnz    err
  106.     mov    dx,cx        ;save counter
  107.     mov    cx,oprm_l-1    ;get string length-1
  108.     repz    cmpsb        ;loop while equal
  109.     je    match        ;strings match?
  110.     mov    cx,dx        ;nope,
  111.     jmp    short again    ; go look again...
  112.  
  113. match:    mov    cx,nprm_len    ;get length of new comspec
  114.     mov    si,offset nprm    ;point to new comspec
  115.     sub    di,oprm_l    ;back-up to begin of old one
  116.     rep    movsb        ;store new comspec
  117.     mov    al,0        ;set ERRORLEVEL = 0
  118.     jmp    short exit
  119.  
  120. err:
  121.     mov    ax,es        ;get current search segment             DMO
  122.     add    ax,1000h    ;increment to next segment             DMO
  123.     mov    cx,ax        ;save for update                 DMO
  124.     mov    ax,cs        ;get our code segment                 DMO
  125.     cmp    cx,ax        ;did we reach our code segment yet?         DMO
  126.     mov    es,cx        ;..in case we did                 DMO
  127.     mov    di,0        ;..beginning of segment              DMO
  128.     jb    bigloop     ;no-continue looking                 DMO
  129.  
  130.     mov    al,1        ;set ERRORLEVEL = 1
  131. exit:    mov    ah,4CH        ;DOS exit function
  132.     int    21H        ;return to DOS
  133.  
  134. start    endp
  135. cseg    ends
  136.     end    start
  137. set ERRORLEVEL = 1
  138. exit:    mov    ah,4CH        ;DOS exit function
  139.     int    21H        ;return to DOS
  140.  
  141. start    endp
  142. cseg    ends
  143.     end    start
  144.